package com.file;

import lombok.Data;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.SimpleFormatter;

public class FileSave {
    public static void main(String[] args) {
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-HH-dd-mm-ss");
        String filename = dateFormat.format(date);
        String filePath = "./data/" + filename + ".txt";
        // 利用java在本地创建文件
        // filePath = "F:\\JavaProgram\\石头剪刀布\\rps\\rockpaperscissors\\src\\main\\java\\com\\file\\test.txt";
        File file = new File(filePath);
        if (!file.exists()) {
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
